﻿<Application x:Class="WOzTestUI.MyApp"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="WizardWindow.xaml"
             
             xmlns:local="clr-namespace:WOzTestUI"
      xmlns:WozLib="clr-namespace:WozLib;assembly=WozLib"
      xmlns:SketchProperty="clr-namespace:WozLib.UI.Ink.SketchProperties;assembly=WozLib"
      xmlns:WozLib-Ink="clr-namespace:WozLib.UI.Ink;assembly=WozLib"
      xmlns:WozLib-Containers="clr-namespace:WozLib.UI.Containers;assembly=WozLib"
      xmlns:WozLib_Controls="clr-namespace:WozLib.UI.Controls;assembly=WozLib"
    >
    <Application.Resources>

      <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="MajorControlBackground">
        <GradientStop Color="AliceBlue" Offset="0"/>
        <GradientStop Color="LightBlue" Offset="1"/>
      </LinearGradientBrush>

      <Style x:Key="ProperyTextBox" TargetType="{x:Type TextBox}">
        <Setter Property="FontWeight" Value="DemiBold"/>
        <Setter Property="FontFamily" Value="Verdana"/>
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="MaxWidth" Value="300"/>
        <Setter Property="TextWrapping" Value="Wrap"/>
        <Setter Property="Margin" Value="2 2 5 2"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="Background">
          <Setter.Value>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
              <LinearGradientBrush.GradientStops>
                <GradientStop Color="Gray" Offset="0"/>
                <GradientStop Color="LightGray" Offset="0.15"/>
                <GradientStop Color="White" Offset="0.8"/>
              </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
      </Style>

      <Style x:Key="ProperyTextBlock" TargetType="{x:Type TextBlock}">
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="FontWeight" Value="Regular"/>
        <Setter Property="FontFamily" Value="Verdana"/>
        <Setter Property="FontSize" Value="13"/>
        <Setter Property="MaxWidth" Value="300"/>
        <Setter Property="TextWrapping" Value="Wrap"/>
        <Setter Property="Margin" Value="2 2 2 2"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Right"/>
      </Style>

      <DrawingBrush x:Name="_GridBrush" x:Key="_GridBrush"
                 Viewport="0,0,10,10" ViewportUnits="Absolute" TileMode="Tile"
                 Opacity="0">
        <DrawingBrush.Drawing>
          <DrawingGroup>
            <GeometryDrawing Brush="#CCCCFF">
              <GeometryDrawing.Geometry>
                <RectangleGeometry Rect="0,0 10,1" />
              </GeometryDrawing.Geometry>
            </GeometryDrawing>
            <GeometryDrawing Brush="#CCCCFF">
              <GeometryDrawing.Geometry>
                <RectangleGeometry Rect="0,0 1,10" />
              </GeometryDrawing.Geometry>
            </GeometryDrawing>
          </DrawingGroup>
        </DrawingBrush.Drawing>
      </DrawingBrush>

      <DataTemplate DataType="{x:Type SketchProperty:OpacityCascadingProperty}">
        <Grid Margin="2">
          <Rectangle Fill="LightGray" Stroke="Black" StrokeThickness="0.5" Margin="0" RadiusX="3" RadiusY="3"/>
          <StackPanel Orientation="Horizontal" Margin="4">

            <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana"
                       FontSize="12" Foreground="Black" Text="{Binding Path=Description}"/>

            <WozLib_Controls:OpacitySelector AllowZero="True" CascadingProperty="{Binding}" SelectedOpacity="{Binding Path=OpacityProperty.Data, Mode=TwoWay}"/>

          </StackPanel>

        </Grid>
      </DataTemplate>

      <DataTemplate DataType="{x:Type SketchProperty:RectGeometryCascadingProperty}">
        <Grid Margin="2">
          <Rectangle Fill="LightGray" Stroke="Black" StrokeThickness="0.5" Margin="0" RadiusX="3" RadiusY="3"/>
          <Expander>
            <Expander.Header>
              <StackPanel Orientation="Horizontal" Margin="4">

                <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana"
                           FontSize="12" Foreground="Black" Text="{Binding Path=Description}"/>

                <!--<TextBox VerticalAlignment="Center" Margin="5,0,5,0"
                       Text="{Binding Path=StringWozProperty.Rect, Mode=TwoWay}"/>-->

              </StackPanel>
            </Expander.Header>
            <Grid>
              <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
              </Grid.ColumnDefinitions>
              <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
              </Grid.RowDefinitions>
              <TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource ProperyTextBlock}" Margin="5,3,5,3" >left</TextBlock>
              <TextBox Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" Margin="5,3,5,3" Style="{StaticResource ProperyTextBox}"
                         Text="{Binding Path=RectGeometryWozProperty.Left, Mode=TwoWay}"/>

              <TextBlock Grid.Column="2" Grid.Row="0" Style="{StaticResource ProperyTextBlock}" Margin="5,3,5,3" >top</TextBlock>
              <TextBox Grid.Column="3" Grid.Row="0" VerticalAlignment="Center" Margin="5,3,5,3" Style="{StaticResource ProperyTextBox}"
                         Text="{Binding Path=RectGeometryWozProperty.Top, Mode=TwoWay}"/>

              <TextBlock Grid.Column="0" Grid.Row="1" Style="{StaticResource ProperyTextBlock}" Margin="5,3,5,3" >width</TextBlock>
              <TextBox Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Margin="5,3,5,3" Style="{StaticResource ProperyTextBox}"
                         Text="{Binding Path=RectGeometryWozProperty.Width, Mode=TwoWay}"/>

              <TextBlock Grid.Column="2" Grid.Row="1" Style="{StaticResource ProperyTextBlock}" Margin="5,3,5,3" >height</TextBlock>
              <TextBox Grid.Column="3" Grid.Row="1" VerticalAlignment="Center" Margin="5,3,5,3" Style="{StaticResource ProperyTextBox}"
                         Text="{Binding Path=RectGeometryWozProperty.Height, Mode=TwoWay}"/>

              <!--hack-->
              <Button Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4"
                      HorizontalAlignment="Left"
                Command="local:WizardWindow.MaximizeRectGeometry"
                CommandParameter="{Binding}" >maximize</Button>

            </Grid>
          </Expander>
        </Grid>
      </DataTemplate>

      <DataTemplate DataType="{x:Type SketchProperty:FontSizeCascadingProperty}">
        <Grid Margin="2">
          <Rectangle Fill="LightGray" Stroke="Black" StrokeThickness="0.5" Margin="0" RadiusX="3" RadiusY="3"/>
          <StackPanel Orientation="Horizontal" Margin="4">

            <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana"
                       FontSize="12" Foreground="Black" Text="{Binding Path=Description}"/>

            <WozLib_Controls:FontSizeSelector
              CascadingProperty="{Binding}"
              SelectedFontSize="{Binding Path=FontSizeProperty.Data, Mode=TwoWay}"/>

          </StackPanel>

        </Grid>
      </DataTemplate>

      <DataTemplate DataType="{x:Type SketchProperty:FontCascadingProperty}">
        <Grid Margin="2">
          <Rectangle Fill="LightGray" Stroke="Black" StrokeThickness="0.5" Margin="0" RadiusX="3" RadiusY="3"/>
          <StackPanel Orientation="Horizontal" Margin="4">

            <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana"
                       FontSize="12" Foreground="Black" Text="{Binding Path=Description}"/>

            <WozLib_Controls:FontSelector
              CascadingProperty="{Binding}"
              SelectedFont="{Binding Path=StringWozProperty.Data, Mode=TwoWay}"/>

          </StackPanel>

        </Grid>
      </DataTemplate>

      <DataTemplate DataType="{x:Type SketchProperty:ColorCascadingProperty}">
        <Grid Margin="2">
          <Rectangle Fill="LightGray" Stroke="Black" StrokeThickness="0.5" Margin="0" RadiusX="3" RadiusY="3"/>
          <StackPanel Orientation="Horizontal" Margin="4">

            <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana"
                       FontSize="12" Foreground="Black" Text="{Binding Path=Description}"/>

            <WozLib_Controls:ColorSelector ColorCascading="{Binding}"  SelectedColor="{Binding Path=ColorWozProperty.Data, Mode=TwoWay}"/>

          </StackPanel>

        </Grid>
      </DataTemplate>

      <DataTemplate DataType="{x:Type SketchProperty:ThicknessCascadingProperty}">
        <Grid Margin="2">
          <Rectangle Fill="LightGray" Stroke="Black" StrokeThickness="0.5" Margin="0" RadiusX="3" RadiusY="3"/>
          <StackPanel Orientation="Horizontal" Margin="4">

            <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana"
                       FontSize="12" Foreground="Black" Text="{Binding Path=Description}"/>

            <WozLib_Controls:ThicknessSelector SelectedThickness="{Binding Path=WozThicknessProperty.Data, Mode=TwoWay}"/>

          </StackPanel>

        </Grid>
      </DataTemplate>

      <DataTemplate DataType="{x:Type SketchProperty:CornerRoundednessCascadingProperty}">
        <Grid Margin="2">
          <Rectangle Fill="LightGray" Stroke="Black" StrokeThickness="0.5" Margin="0" RadiusX="3" RadiusY="3"/>
          <StackPanel Orientation="Horizontal" Margin="4">

            <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana"
                       FontSize="12" Foreground="Black" Text="{Binding Path=Description}"/>

            <WozLib_Controls:CornerRoundednessSelector CascadingProperty="{Binding}" SelectedRoundedness="{Binding Path=CornerRoundednessWozProperty.Data, Mode=TwoWay}"/>

          </StackPanel>

        </Grid>
      </DataTemplate>

      <DataTemplate DataType="{x:Type SketchProperty:InkThicknessCascadingProperty}">
        <Grid Margin="2">
          <Rectangle Fill="LightGray" Stroke="Black" StrokeThickness="0.5" Margin="0" RadiusX="3" RadiusY="3"/>
          <StackPanel Orientation="Horizontal" Margin="4">

            <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana"
                       FontSize="12" Foreground="Black" Text="{Binding Path=Description}"/>

            <WozLib_Controls:ThicknessSelector AllowZero="False" CascadingProperty="{Binding}" SelectedThickness="{Binding Path=WozThicknessProperty.Data, Mode=TwoWay}"/>

          </StackPanel>

        </Grid>
      </DataTemplate>

      <DataTemplate DataType="{x:Type SketchProperty:BooleanCascadingProperty}">
        <Grid Margin="2">
          <Rectangle Fill="LightGray" Stroke="Black" StrokeThickness="0.5" Margin="0" RadiusX="3" RadiusY="3"/>
          <StackPanel Orientation="Horizontal" Margin="4">

            <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana"
                       FontSize="12" Foreground="Black" Text="{Binding Path=Description}"/>

            <CheckBox VerticalAlignment="Center" Margin="5,0,5,0" IsChecked="{Binding Path=BooleanWozProperty.Data, Mode=TwoWay}"/>

          </StackPanel>

        </Grid>
      </DataTemplate>
      
      <DataTemplate DataType="{x:Type SketchProperty:LinkCascadingProperty}">
        <Grid Margin="2">
          <Rectangle Fill="LightGray" Stroke="Black" StrokeThickness="0.5" Margin="0" RadiusX="3" RadiusY="3"/>
          <StackPanel Orientation="Horizontal" Margin="4">

            <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana"
                       FontSize="12" Foreground="Black" Text="Linked View"/>

            <TextBox VerticalAlignment="Center" Margin="5,0,5,0" MaxWidth="250"
                     AcceptsReturn="True" AcceptsTab="True" TextWrapping="Wrap"
                     Text="{Binding Path=LongWozProperty.Data, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                     MinWidth="100"
                     PreviewMouseDown="_TextBox_SelectAll_PreviewMouseDown"
                                   GotFocus="_TextBox_SelectAll_GotFocus"
                     />

          </StackPanel>

        </Grid>
      </DataTemplate>

      <DataTemplate DataType="{x:Type SketchProperty:StringCascadingProperty}">
        <Grid Margin="2">
          <Rectangle Fill="LightGray" Stroke="Black" StrokeThickness="0.5" Margin="0" RadiusX="3" RadiusY="3"/>
          <StackPanel Orientation="Horizontal" Margin="4">

            <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana"
                       FontSize="12" Foreground="Black" Text="{Binding Path=Description}"/>

            <TextBox VerticalAlignment="Center" Margin="5,0,5,0" MaxWidth="250"
                     AcceptsReturn="True" AcceptsTab="True" TextWrapping="Wrap"
                     Text="{Binding Path=StringWozProperty.Data, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                     MinWidth="100" 
                     PreviewMouseDown="_TextBox_SelectAll_PreviewMouseDown"
                                   GotFocus="_TextBox_SelectAll_GotFocus"
                     />

          </StackPanel>

        </Grid>
      </DataTemplate>

      <Style x:Key="AddButtonStyleBlue" TargetType="{x:Type Button}">
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate>
              <Grid Width="20" Height="20">
                <Rectangle x:Name="buttonRectangle" RadiusX="5" RadiusY="5" StrokeThickness="2" Stroke="{TemplateBinding Property=BorderBrush}" Fill="{TemplateBinding Property=Background}">
                  <Rectangle.BitmapEffect>
                    <OuterGlowBitmapEffect GlowSize="3" GlowColor="Blue" Opacity="0" x:Name="ButtonGlow"/>
                  </Rectangle.BitmapEffect>
                </Rectangle>
                <Line Stroke="{TemplateBinding Property=Foreground}" StrokeThickness="2" X1="4" X2="16" Y1="10" Y2="10" />
                <Line Stroke="{TemplateBinding Property=Foreground}" StrokeThickness="2" X1="10" X2="10" Y1="4" Y2="16" />
              </Grid>
              <ControlTemplate.Triggers>
                <EventTrigger RoutedEvent="Button.MouseEnter">
                  <EventTrigger.Actions>
                    <BeginStoryboard>
                      <Storyboard>
                        <DoubleAnimation
                          Storyboard.TargetName="ButtonGlow"
                          Storyboard.TargetProperty="Opacity"
                          To="1" Duration="0:0:0.1"/>
                      </Storyboard>
                    </BeginStoryboard>
                  </EventTrigger.Actions>
                </EventTrigger>
                <EventTrigger RoutedEvent="Button.MouseLeave">
                  <EventTrigger.Actions>
                    <BeginStoryboard>
                      <Storyboard>
                        <DoubleAnimation
                          Storyboard.TargetName="ButtonGlow"
                          Storyboard.TargetProperty="Opacity"
                          AccelerationRatio="0.2"
                          DecelerationRatio="0.4"
                          To="0" Duration="0:0:0.3"/>
                      </Storyboard>
                    </BeginStoryboard>
                  </EventTrigger.Actions>
                </EventTrigger>
              </ControlTemplate.Triggers>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>

      <Style x:Key="TextBoxLabel" TargetType="{x:Type TextBlock}">
        <Setter Property="FontWeight" Value="DemiBold"/>
        <Setter Property="FontFamily" Value="Verdana"/>
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="Margin" Value="2"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
      </Style>

      <Style x:Key="ScreenProperyTextBox" TargetType="{x:Type TextBox}">
        <Setter Property="FontWeight" Value="DemiBold"/>
        <Setter Property="FontFamily" Value="Verdana"/>
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="MaxWidth" Value="300"/>
        <Setter Property="TextWrapping" Value="Wrap"/>
        <Setter Property="Margin" Value="2 2 5 2"/>
      </Style>

      <Style x:Key="ToolBarButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Margin" Value="3 1 3 1"/>
        <!--<Setter Property="Background">
        <Setter.Value>
          <SolidColorBrush Color="SkyBlue" Opacity="0.18" />
        </Setter.Value>
      </Setter>-->
        <!--<Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type Button}">
            <Grid VerticalAlignment="Center">
              <Rectangle x:Name="BackTangle" Fill="SkyBlue" Opacity="0.25" RadiusX="5" RadiusY="5"/>
              <ContentPresenter Content="{TemplateBinding Content}" Margin="3 2 3 2" />
            </Grid>
            <ControlTemplate.Triggers>
              <EventTrigger RoutedEvent="Button.MouseEnter">
                <EventTrigger.Actions>
                  <BeginStoryboard>
                    <Storyboard>
                      <DoubleAnimation 
                        Storyboard.TargetName="BackTangle"
                        Storyboard.TargetProperty="Opacity"
                        To="0.7" Duration="0:0:0.1"/>
                    </Storyboard>
                  </BeginStoryboard>
                </EventTrigger.Actions>
              </EventTrigger>
              <EventTrigger RoutedEvent="Button.MouseLeave">
                <EventTrigger.Actions>
                  <BeginStoryboard>
                    <Storyboard>
                      <DoubleAnimation 
                        Storyboard.TargetName="BackTangle"
                        Storyboard.TargetProperty="Opacity"
                        AccelerationRatio="0.2"
                        DecelerationRatio="0.4"
                        To="0.25" Duration="0:0:0.3"/>
                    </Storyboard>
                  </BeginStoryboard>
                </EventTrigger.Actions>
              </EventTrigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>-->
      </Style>



    </Application.Resources>
</Application>
